package cn.iocoder.yudao.module.wine.dal.mysql.commentreport;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.wine.dal.dataobject.commentreport.CommentReportDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.commentreport.vo.*;

/**
 * 评论举报记录 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CommentReportMapper extends BaseMapperX<CommentReportDO> {

    default PageResult<CommentReportRespVO> selectPage(CommentReportPageReqVO reqVO) {
        return selectJoinPage(reqVO, CommentReportRespVO.class,new MPJLambdaWrapperX<CommentReportDO>()
                .eqIfPresent(CommentReportDO::getUserId, reqVO.getUserId())
                .eqIfPresent(CommentReportDO::getContent, reqVO.getContent())
                .eqIfPresent(CommentReportDO::getCommentId, reqVO.getCommentId())
                .betweenIfPresent(CommentReportDO::getCreateTime, reqVO.getCreateTime())
                .leftJoin(MemberUserDO.class,MemberUserDO::getId,CommentReportDO::getUserId)
                .likeIfExists(MemberUserDO::getNickname,reqVO.getNickname())
                .selectAll(CommentReportDO.class)
                .selectAs(MemberUserDO::getNickname,CommentReportRespVO::getNickname)
                .selectAs(MemberUserDO::getName,CommentReportRespVO::getName)
                .orderByDesc(CommentReportDO::getId));
    }

}
